package org.example.GC;

import java.util.Stack;

public class MyQueue {
    private Stack<Integer> stack1 = new Stack<>();
    private Stack<Integer> stack2 = new Stack<>();

    public MyQueue() {

    }

    public void push(int x) {
        stack1.push(x);
    }

    public int pop() {
        int top = peek();
        if (!stack2.isEmpty()){
            top=peek();
            stack2.pop();
            return top;
        }
        return top;
    }

    public int peek() {
        if (stack2.isEmpty()){
            while (!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        if (!stack2.isEmpty()){
            return stack2.peek();
        }
        return -1;
    }

    public boolean empty() {
        return (stack1.isEmpty()&&stack2.isEmpty())?true:false;
    }
}
